home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / interp / perl5.005.tar.gz / perl5.005.tar / perl5.005 / pod / splitpod < prev   
Text File  |  1998-07-19  |  1KB  |  61 lines

  1. #!/usr/bin/perl
  2.  
  3. use lib '../lib';  # If you haven't installed perl yet.
  4. use Pod::Functions;
  5.  
  6. local $/ = '';
  7.  
  8. $cur = '';
  9. while (<>) {
  10.  
  11.     next unless /^=(?!cut)/ .. /^=cut/;
  12.  
  13.     if (s/=item (\S+)/$1/) {
  14.     #$cur = "POSIX::" . $1;
  15.     $next{$cur} = $1;
  16.     $cur = $1;
  17.     $syn{$cur} .= $_;
  18.     next;
  19.     } else { 
  20.     #s,L</,L<POSIX/,g;
  21.     s,L</,L<perlfunc/,g;
  22.     push @{$pod{$cur}}, $_ if $cur;
  23.     }
  24.  
  25. for $f ( keys %syn ) {
  26.     next unless $Type{$f};
  27.     $flavor = $Flavor{$f};
  28.     $orig = $f;
  29.     ($name = $f) =~ s/\W//g;
  30.  
  31.     # deal with several functions sharing a description
  32.     $func = $orig;
  33.     $func = $next{$func} until $pod{$func};
  34.     my $body = join "", @{$pod{$func}};
  35.  
  36.     # deal with unbalanced =over and =back cause by the split
  37.     my $has_over = $body =~ /^=over/;
  38.     my $has_back = $body =~ /^=back/;
  39.     $body =~ s/^=over\s*//m if $has_over and !$has_back;
  40.     $body =~ s/^=back\s*//m if $has_back and !$has_over;
  41.     open (POD, "> $name.pod") || die "can't open $name.pod: $!";
  42.     print POD <<EOF;
  43. =head1 NAME
  44.  
  45. $orig - $flavor
  46.  
  47. =head1 SYNOPSIS
  48.  
  49. $syn{$orig}
  50.  
  51. =head1 DESCRIPTION
  52.  
  53. $body
  54.  
  55. EOF
  56.  
  57.     close POD;
  58.  
  59.